<label><?=$label?></label>
<?
    switch($type) {
        case "text" :
?>       
        <input type="text" name="<?=$name?>" value="<?=$value?>" />
<?
        break;
        
        case "select" :
?>
        <select name="<?=$name?>">
            <option value="">---- Select -----</option>
			<?
				foreach( $data as $dataitem  ) {
                    if($value == $dataitem["value"])
						echo "<option value='".$dataitem["value"]."' selected='true' >".$dataitem["label"]."</option>";
					else
					    echo "<option value='".$dataitem["value"]."'>".$dataitem["label"]."</option>";
				}
			?>
        </select>
<?        
        break;
        
        case "radio" :
            foreach( $data as $dataitem  ) {
            ?>
                <input value="<?=$dataitem["value"]?>" type="radio" <? if($value==$dataitem["value"]) echo "CHECKED=\"true\""; ?> name="<?=$name?>"/>
                <label><?=$dataitem["label"]?></label>
            <?
			}
        break;
        
        case "checkbox" :
            foreach( $data as $dataitem  ) {
            ?>
                <input value="<?=$dataitem["value"]?>" type="checkbox" <? if(is_array($value) && in_array($dataitem["value"],$value)) echo "CHECKED=\"true\""; ?> name="<?=$name?>[]"/>
                <label><?=$dataitem["label"]?></label>
            <?
			}
        break;
        
        case "date" :
        ?>
            <input type="text" readonly="true" class="stext" name="<?=$name?>" value="<?=$value?>" />
            <script language="javascript" type="text/javascript">
                $(document).ready( function() {
                    $("input[name='<?=$name?>']").datepicker({ 
                        dateFormat: 'yy-mm-dd',
                        changeMonth: true,
						<? if(isset($maxDate)) { echo "maxDate: $maxDate,"; } ?>
                        changeYear: true
                    });    
                });
            </script>
        <?
        break;        
    }    
?>